#include "stdafx.h"
#include "Smoke.h"

#include "../../Framework/ContentManager.h"

namespace MyGame {

Smoke::Smoke(Game* game) : Quad(game) {
    this->SetEffectFile("Smoke.fx");
}

Smoke::~Smoke(void) {
}

void Smoke::Draw(FLOAT timeDelta) {
    D3DXVECTOR3 vLightDir = D3DXVECTOR3(1, 1, 1);
    D3DXVec3Normalize(&vLightDir, &vLightDir);
    D3DXCOLOR vLightDiffuse = D3DXCOLOR(1, 1, 1, 1);
    this->effect->SetValue("g_LightDir", &vLightDir, sizeof(D3DXVECTOR3));
    this->effect->SetValue("g_LightDiffuse", &vLightDiffuse, sizeof(D3DXCOLOR)) ;

    D3DXMATRIX mWorld = this->GetWorldMatrix();
    D3DXMATRIX mWorldViewProjection = mWorld * this->GetGame()->GetCamera()->GetViewMatrix() * this->GetGame()->GetCamera()->GetProjectionMatrix();
    this->effect->SetMatrix("g_mWorldViewProjection", &mWorldViewProjection) ;
    this->effect->SetMatrix("g_mWorld", &mWorld) ;
    this->effect->SetFloat("g_Alpha", 1 - this->GetAlpha());
    this->effect->SetTechnique("Particle_Shader_Normal_Alpha");

    D3DXCOLOR colorMtrlAmbient(0.7f, 0.7f, 0.7f, 0.5f);
    D3DXCOLOR colorMtrlDiffuse(1.0f, 1.0f, 1.0f, 0.5f);
    this->effect->SetValue("g_MaterialAmbientColor", &colorMtrlAmbient, sizeof(D3DXCOLOR));
    this->effect->SetValue("g_MaterialDiffuseColor", &colorMtrlDiffuse, sizeof(D3DXCOLOR));

    __super::Draw(timeDelta);
}

}
